package com.example.rest.controller;

//import com.sun.media.jfxmedia.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.example.rest.model.UserModel2;
import com.example.rest.service.DeleteService;
import com.example.rest.service.GetService;
import com.example.rest.service.PostService;
import com.example.rest.service.PutService;

/**
 * @BelongsProject: RestTemplate
 * @BelongsPackage: com.example.rest.controller
 * @Author:hlzs1
 * @Description: 用来做测试的Controller
 * @CreateTime: 2023-02-28 09:07
 * @Version: 1.0
 */
@RestController
public class TestController {

    @Autowired
    private GetService getService;

    @GetMapping("/getTest")
    public String getTest(){
       return getService.getForEntity();
    }

    @GetMapping("/getTest2")
    public String getTest2(){
        return getService.getForEntity2();
    }

    @GetMapping("/getTest3")
    public String getTest3(){
        return getService.getForEntity3();
    }


    @GetMapping("/getTest4")
    public String getTest4(){
        return getService.getForObject();
    }

    @GetMapping("/getTest5")
    public String getTest5(){
        return getService.getForObject2();
    }

    @GetMapping("/getTest6")
    public String getTest6(){
        return getService.getForObject3();
    }


    @Autowired
    private PostService postService;

    @GetMapping("/postTest")
    public String postTest(){
        return postService.postForEntity();
    }

    @GetMapping("/postTest2")
    public String postTest2(){
        return postService.postForEntity2();
    }

    @GetMapping("/postTest3")
    public String postTest3(){
        return postService.postForObject();
    }


    @Autowired
    private PutService putService;

    @GetMapping("/put")
    public void put(){
         putService.put();
    }

    @GetMapping("/put2")
    public void put1(){
         putService.put2();
    }


    @Autowired
    private DeleteService deleteService;

    @GetMapping("/delete")
    public void delete1(){
        deleteService.delete();
    }



    @PostMapping("/csdn")
    public String csdn(@RequestBody UserModel2 userModel2){
        System.out.println("enter csdn");
        try {
         return  deleteService.csdn(userModel2);
        }catch (Exception e){
            System.out.println(e);
            return "error" + e;
        }

    }
}
